#ifndef MAIN_WINDOW_H_
#define MAIN_WINDOW_H_

#include <vector>
#include <GL/glew.h>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/OpenGL.hpp>
#include <string>
#include "Terrain.h"
#include "SkyBox.h"
#include "Water.h"
#include "Model.h"
#include "ModelInstance.h"
#include "GrassCluster.h"
#include "Plane.h"

class MainWindow : public sf::RenderWindow {
public:
    MainWindow(int width, int height, std::string title);
    ~MainWindow();
    void render();
    void setClock(sf::Clock *clock);
    void adjustCamera(float x, float y, float z);
    void setRotation(GLfloat yaw, GLfloat pitch);
    void adjustRotation(GLfloat yaw, GLfloat pitch);
    void moveLeft(GLfloat speed);
    void moveRight(GLfloat speed);
    void moveForward(GLfloat speed);
    void moveBackward(GLfloat speed);
    void setupShaders();
    void setTerrain(std::string filename);
    void setSkybox(std::string filename);
	void setWater(std::string filename);
    void loadingScreen(std::string loadingText);
    void loadModels();
    void printFPS();
    void setupViewport();
    void adjustPlanePitch(GLfloat angle);
    void adjustPlaneRoll(GLfloat angle);
    void adjustPlaneYaw(GLfloat angle);
    void adjustPlaneSpeed(GLfloat speed);
    void keyHandler(sf::Keyboard::Key key);
    void lockOnPlane();
protected:
    virtual void onResize();
    virtual void onCreate();
private:
    void planeCollision();
    GLuint loadShaderSource(std::string filename, GLuint shaderType);
    void renderInstanceList();
    float FOV;
    float zNear;
    float zFar;
    GLfloat yaw;
    GLfloat pitch;
	GLfloat	camPos[3];
    Terrain *terrain;
	SkyBox	*skybox;
	Water	*water;
    sf::Clock* clock;
    GLuint terrainShaderProg;
    GLuint skyShaderProg;
	GLuint waterShaderProg;
    GLuint modelShaderProg;
    std::vector<Model*> modelList;
    std::vector<ModelInstance*> instanceList;
    Plane *plane;
    Grass *g;
    GrassCluster *gc;
    bool flying;
};

#endif /* MAIN_WINDOW_H_ */
